#ifndef STATE_H_
#define STATE_H_

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>

#include "Timer.h"
#include "Bug.h"
#include "Square.h"
#include "Location.h"
#include "target.h"

#include "task.h"
/*
    constants
*/
const int TDIRECTIONS = 4;
const char CDIRECTIONS[5] = {'N', 'E', 'S', 'W', 'U'};
const int DIRECTIONS[5][2] = { {-1, 0}, {0, 1}, {1, 0}, {0, -1}, {0,0} };      //{N, E, S, W}



/*
    struct to store current state information
*/
struct State
{
    /*
        Variables
    */
    int rows, cols,
        turn, turns,
        noPlayers;
    double attackradius, spawnradius, viewradius;
    double loadtime, turntime;
    std::vector<double> scores;
    bool gameover;

    std::vector<std::vector<Square> > grid;
    std::vector<Hill> myHills, enemyHills;
    std::vector<Food> food;
    Target::AntVector enemyAnts,myAnts;
    Target::AntVector freeAnts;

    Target target;

    Target::TaskVector uncharted;

    TargetTask tasks;



    Timer timer;
    Bug bug;

    /*
        Functions
    */
    State();
    ~State();

    void setup();
    void reset();

    //void makeMove(const Location &loc, int direction);
    void makeMovies();
    //void tryMove(const Ant& ant, const Task& task);
    bool canMove(const Location& from, const Location& to) const;

    //bool getTask(const Ant& ant, WeightTask& task, bool enumerateOccuped);


    double distance(const Location &loc1, const Location &loc2) const;
    Location getLocation(const Location &startLoc, int direction) const;
    int GetDirection(const Location& from, const Location& to) const;
    Location GetMapResolution() const {  return Location(rows,cols);}

    void updateVisionInformation();
};

std::ostream& operator<<(std::ostream &os, const State &state);
std::istream& operator>>(std::istream &is, State &state);
std::ostream& operator<<(std::ostream &os, const Location &loc);

#endif //STATE_H_
